/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package apus.command;

import apus.entity.AbstractEntity;
import apus.persistence.AbstractDAO;
import apus.services.ServiceLocator;

/**
 * The <code>ViewListCommand</code> class represents command for view list of 
 * entity.
 * @author  Roman Dyatkovsky
 * @author  Maxim Vasilevsky
 * @since APUS v0.3
 * @see AbstractCommand
 */
public class ViewListCommand<TypeEn extends AbstractEntity,TypeDAO extends AbstractDAO<TypeEn>> extends AbstractCommand {
    private Class<TypeDAO> clazz;
    
    public ViewListCommand(Class<TypeDAO> clazz) {
        super("View list");
        this.clazz=clazz;
    }

    @Override
    public void execute() {
        AbstractDAO<TypeEn> DAO = ServiceLocator.getService(clazz);     
 
        for(TypeEn ent : DAO.findAll()) {
            System.out.println("ID=" + ent.getId() + " " + ent.toString());
        }   
    }
}
